package com.antsoft.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.antsoft.database.mybatis.ReadOnlyConnection;
import com.antsoft.database.mybatis.ReadOnlyConnectionInterceptor;
import com.antsoft.mapper.DicTypeMapper;
import com.antsoft.mapper.TblUserMapper;
import com.antsoft.model.DicType;
import com.antsoft.model.TblUser;
import com.github.pagehelper.PageHelper;

/**
 * Created by Jason on 2017/3/2.
 */
@Service
public class DicTypeService {
	public static final Logger logger = LoggerFactory.getLogger(ReadOnlyConnectionInterceptor.class);
	   
    @Autowired
    private DicTypeMapper dicTypeMapper;
    
    @Autowired
    private TblUserMapper tblUserMapper;

    public List<DicType> getAll(DicType dicType){
        if (dicType.getPage() != null && dicType.getRows() != null) {
            PageHelper.startPage(dicType.getPage(), dicType.getRows());
        }
        return dicTypeMapper.selectAll();
    }

    @ReadOnlyConnection  
    @Transactional(readOnly = false)
    public TblUser getAllUser(){
    	logger.info("执行中");
        return (TblUser) tblUserMapper.selectByPrimaryKey(4);
    }
}
